export default {
  // Global page headers: https://go.nuxtjs.dev/config-head\
  mode:'universal',
  server:{
    port:3000, //default 3000
    host: '0.0.0.0'
  },
  head: { 
    title: process.env.npm_package_name || '统一标题', //统一标题
    meta: [ 
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' }, //移动端
      { hid: 'description', name: 'description', content: '自定义描述信息' },
      { name: 'format-detection', content: 'telephone=no' }
    ],
    // script:[
    //   {src:'http://code.jquery.com/jquery-latest.js'}
    // ],
    link: [
      { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
      {rel:'stylesheet',href:'http://fonts.useso.com/css?family=Ubuntu'}
    ]
  },
  router:{
    middleware:'auth',

    //扩展路由
    extendRoutes(routes,resolve){
      console.log(routes);
      routes.push({
        name:'home',
        path:'/index',
        component: resolve(__dirname,'pages/index.vue')
      })
    }
  },

  // 定义系统默认loading效果，或者指定loading组件
  loading:'~/components/loading.vue',

  // Global CSS: https://go.nuxtjs.dev/config-css
  css: [
    'assets/css/base.css',
    'assets/css/transition.css',
    'element-ui/lib/theme-chalk/index.css'
  ],

  // Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
  plugins: [
    '~/plugins/router',
    {
      src:'~/plugins/axios',
      ssr:true //服务端
    },
    {
      src:'~/plugins/element-ui',
      ssr:true, //不支持ssr 只会在客户端渲染选择false
      // mode:'server' //clien //v2.4+
    },
    '~/plugins/mixins'
  ],

  // Auto import components: https://go.nuxtjs.dev/config-components
  components: true,

  // Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
  buildModules: [
    '@nuxt/typescript-build'
  ],

  // Modules: https://go.nuxtjs.dev/config-modules
  modules: [
    '@nuxtjs/axios',
    'cookie-universal-nuxt',
    '@nuxtjs/style-resources'
  ],
  styleResources:{
    scss:[
      './assets/scss/global.scss'
    ]
  },
  asios:{
    proxy:true, //开启跨域
    // prefix:'/api' //baseUrl
  },
  proxy:{
    '/api/':{
      target:'http://localhost:3001', //代理转发地址
      changeOrigin:true,
      pathRewrite:{
        // '^/api':''
      }
    }
  },
  // Build Configuration: https://go.nuxtjs.dev/config-build
  build: {
    transpile:[/^element-ui/],
  }
}
